package com.jmga.ecogasfinder.receivers;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class OnBootReceiver extends BroadcastReceiver {

	private static final int ALARM_REQUEST_CODE = 0;

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.d(getClass().getName(), "Phone's just turned on");
		
		Intent alarmsIntent = new Intent(context, AlarmsReceiver.class);
	    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, ALARM_REQUEST_CODE, alarmsIntent, PendingIntent.FLAG_CANCEL_CURRENT);
	    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
	    alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 
	    		86400000, pendingIntent); //6000 = 1 minuto // 300000 = 5 minutos // 3600000 = 1 hora // 86400000 = 24 horas
	}

}
